library(class)
trainset<-read.table("sat.trn", header = FALSE, sep="")
testset<-read.table("sat.tst", header = FALSE, sep="")
 
 nrow <- length(testset[,1])
 ncol <- length(trainset[1,])
 pred <- knn(trainset[,1:(ncol-1)], testset[,1:(ncol-1)], trainset[,ncol], k=3)
 acc <- sum(pred == testset[,ncol])/(nrow)
 acc